import os
from typing import IO
from src.db import dbs, dbm
from typing import Annotated
from pydantic import BaseModel
from pydantic import Field, AfterValidator


# 自定义验证函数
class _Validate:
    def on_empty(v: str) -> str:
        if not v.strip():
            raise ValueError(f"字段值不能为空")
        return v


class file_exchanger_schema(BaseModel):
    """服务迁移"""

    time_dir: Annotated[str, AfterValidator(_Validate.on_empty)] = Field(
        ..., min_length=1, description="时间戳目录"
    )
    running_pool: Annotated[str, AfterValidator(_Validate.on_empty)] = Field(
        ..., min_length=1, description="运行池类型"
    )
